package com.heima.admin.controller.v1;

import com.heima.admin.service.ChannelService;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class ChannelController{

    @Autowired
    private ChannelService channelService;

    /**
     * 删除频道
     * @param id
     * @return
     */
    @GetMapping("del/{id}")
    public ResponseResult delChannel(@PathVariable Integer id){
        return channelService.delChannel(id);
    }

    /**
     * 分页查询频道列表
     * @param dto
     * @return
     */
    @PostMapping("list")
    public ResponseResult listChannel(@RequestBody ChannelDto dto){
        return channelService.listChannel(dto);
    }

    /**
     * 保存频道信息
     * @param dto
     * @return
     */
    @PostMapping("save")
    public ResponseResult saveChannel(@RequestBody WmChannel dto){
        return channelService.saveChannel(dto);
    }

    @PostMapping("update")
    public ResponseResult updateChannel(@RequestBody WmChannel dto){
        return channelService.updateChannel(dto);
    }
}
